@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';

@mixin icon-fill($color) {
  .icon {
    color: $color;
  }
}

@mixin label-color($color) {
  .label {
    color: $color;
  }
}

@mixin icon-size($icon-sizes, $size) {
  .icon {
    display: inline-flex;

    svg {
      width: $icon-s !important; /* stylelint-disable-line declaration-no-important */
      height: $icon-s !important; /* stylelint-disable-line declaration-no-important */
    }
  }
}

@mixin button-anatomy-styles($button-theme, $sizes, $variants, $typography, $hasLabel: true) {
  @each $size in $sizes {
    &[data-size='#{$size}'] {
      @if $hasLabel == true {
        .label {
          @include composite-var($typography, $size);
        }
      }

      .icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;

        width: $icon-s;
        height: $icon-s;

        svg {
          max-width: $icon-s;
          max-height: $icon-s;
        }
      }

      @each $variant in $variants {
        &[data-variant='#{$variant}'] {
          @include composite-var($button-theme, 'container', $size, $variant);
        }
      }
    }
  }
}

@mixin loading-label-only($button-theme) {
  &[data-loading][data-variant='label-only'] {
    .icon {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }

    .label {
      @include composite-var($button-theme, 'label', 'load-label-only');
    }
  }
}

@mixin button-common-state {
  &:focus-visible {
    @include outline-var($container-focused-s);

    outline-offset: $spacing-state-focus-offset;
  }
}
